{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "b1859099-cbf7-4658-a586-5c6ee981caf9",
   "metadata": {},
   "source": [
    "# Category Heatmap\n",
    "\n",
    "A heatmap showing the relationship between two categorical variables. This example uses the `earthquakes` dataset to count occurrences by magnitude and depth class."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "eff0310c-b4b2-4d87-8cad-3fbebf45243b",
   "metadata": {},
   "outputs": [],
   "source": [
    "import hvplot.pandas  # noqa\n",
    "import numpy as np\n",
    "\n",
    "df = hvplot.sampledata.earthquakes('pandas')\n",
    "\n",
    "df.hvplot.heatmap(\n",
    "    x='mag_class',\n",
    "    y='depth_class',\n",
    "    C='mag',\n",
    "    reduce_function=np.size,\n",
    "    fields={'mag': 'count'},  # for the tooltip to display count instead of mag \n",
    "    logz=True,\n",
    "    title='Category Heatmap (Bokeh)',\n",
    "    xlabel='Magnitude Class',\n",
    "    ylabel='Depth Class',\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "52a57fa1-797f-4860-a3ef-0f6fb2bbc510",
   "metadata": {},
   "outputs": [],
   "source": [
    "import hvplot.pandas  # noqa\n",
    "import numpy as np\n",
    "hvplot.extension('matplotlib')\n",
    "\n",
    "df = hvplot.sampledata.earthquakes('pandas')\n",
    "\n",
    "df.hvplot.heatmap(\n",
    "    x='mag_class',\n",
    "    y='depth_class',\n",
    "    C='mag',\n",
    "    reduce_function=np.size,\n",
    "    fields={'mag': 'count'},  # for the tooltip to display count instead of mag \n",
    "    logz=True,\n",
    "    title='Category Heatmap (Matplotlib)',\n",
    "    xlabel='Magnitude Class',\n",
    "    ylabel='Depth Class',\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9f7d30a6-be2b-4af2-9d1a-454e0cce93b1",
   "metadata": {},
   "source": [
    ":::{seealso}\n",
    "- [Heatmap reference documentation](../../ref/api/manual/hvplot.hvPlot.heatmap.ipynb).\n",
    ":::"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
